package com.kai.steering.data.service.databus.enums;

/**
 * @ Author     ：LiuKai.
 * @ Date       ：Created in 17:20 2022-3-11
 * @ Description：存在 枚举
 * @ Modified By：
 * @Version:
 */
public enum UsableEnum {

    ACTIVE(0, "活跃", true),
    DELETE(1, "删除", false);

    private int code;

    private String value;

    private boolean bool;

    UsableEnum(int code, String value, boolean bool) {
        this.code = code;
        this.value = value;
        this.bool = bool;
    }

    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public boolean isBool() {
        return bool;
    }

    public static Integer getCodeByBool(boolean bool) {
        for (UsableEnum type : UsableEnum.values()) {
            if (type.isBool() == bool) {
                return type.getCode();
            }
        }
        return null;
    }

    public static String getValueByCode(int code) {
        for (UsableEnum type : UsableEnum.values()) {
            if (type.getCode() == code) {
                return type.getValue();
            }
        }
        return null;
    }
}
